import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {AuditRuleQuery, RuleForm} from "@/api/auditRule/types";

/**
 * 稽核规则分页数据
 *
 * @param queryParams
 */
export function getAuditRulePage(
	queryParams: AuditRuleQuery
): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/auditRule/page',
		method: 'get',
		params: queryParams
	});
}

/**
 * 获取稽核规则表单数据
 *
 * @param queryParams
 */
export function getAuditRuleForm(ruleId: number): AxiosPromise<RuleForm> {
	return request({
		url: '/api/v1/auditRule/' + ruleId + '/form',
		method: 'get'
	});
}

/**
 * 保存店铺
 *
 * @param data
 */
export function saveAuditRule(data: RuleForm) {
	return request({
		url: "/api/v1/auditRule",
		method: "post",
		data: data,
	});
}

/**
 * 删除店铺
 *
 * @param ids
 */
export function deleteAuditRule(ids: string) {
	return request({
		url: '/api/v1/auditRule/' + ids,
		method: 'delete'
	});
}

/**
 * 修改稽核规则
 *
 * @param id
 * @param data
 */
export function updateAuditRule(id: number, data: RuleForm) {
	return request({
		url: '/api/v1/auditRule/' + id,
		method: 'put',
		data: data
	});
}
